[]
dashboard.VisualNS.SelectionManager
选择管理器用于管理选择状态,并触发交叉过滤器。
• new SelectionManager()
▸ clear(id?): Promise<void>
清除选定的 SelectionId,或清除所有SelectionId。
| 名称 | 类型 | 描述 |
|---|---|---|
id? |
SelectionId | SelectionId[] |
selectionId,如果不传,代表清除所有selectionId。 |
Promise<void>
▸ contains(id): boolean
返回一个 bool 值, 判断是否已包含目标 selectionId。
| 名称 | 类型 | 描述 |
|---|---|---|
id |
SelectionId |
The selectionId. |
boolean
▸ getCount(): number
获取选中的 selectionId 的数量。
number
▸ getSelectionIds(): SelectionId[]
获值函数。
▸ isEmpty(): boolean
返回一个 bool 值, 判断 selectionId 是否为空。
boolean
▸ registerOnSelectCallback(onSelectCallback): any
注册一个回调函数,当有任何选择状态变化时,回调将被调用。
| 名称 | 类型 | 描述 |
|---|---|---|
onSelectCallback |
(ids: SelectionId[]) => void |
回调函数。 |
any
示例代码
this.selectionManager.registerOnSelectCallback(() => {
//在选择状态更改时,应更新UI,以高亮显示已选择状态。
this.render();
});
▸ select(id, multiSelect): Promise<void>
选择一个或几个 selectionId,它会返回一个 promise,并将在当前选择完成后 resolve。
| 名称 | 类型 | 描述 |
|---|---|---|
id |
SelectionId | SelectionId[] |
selectionId |
multiSelect |
boolean |
支持选择多个 selectionId |
Promise<void>
示例代码
private clickHandler = (node: any) => {
d3.event.stopPropagation();
// 获取绑定在数据模型上的 selectionId。
const selectionId = node.data.selectionId
// 如果已经选中,则取消选中。
if (!this.selectionManager.contains(selectionId)) {
this.selectionManager.select(selectionId, true);
} else {
this.selectionManager.clear(selectionId);
}
// 显示工具提示
this.visualHost.toolTipService.show({
position: {
x: d3.event.x,
y: d3.event.y,
},
title: node.data.color,
fields: [{
label: this.valueField,
value: node.data.value,
}],
selectionId: node.data.selectionId, // tooltip中显示的字段
selected: this.selectionManager.getSelectionIds(), // 所有选定的 selectionId,将用于保留、排除或钻取
menu: true,
});
}
▸ setSelectionIds(ids): void
设值函数。
| 名称 | 类型 |
|---|---|
ids |
SelectionId[] |
void